package com.atguigu3.common_algorithm.exer2;

/**
 * ClassName: arrary_test2
 * Description:
 *（1）在编程竞赛中，有10位评委为参赛的选手打分，分数分别为：5,4,6,8,9,0,1,2,7,3
 * （2）求选手的最后得分（去掉一个最高分和一个最低分后其余8位评委打分的平均值）
 * @Author liu
 * @Create 2024/8/11 16:59
 * @Version 1.0
 */

public final class arrary_test2 {
    public static void main(String[] arges){
        int[] arr = {5,4,6,8,9,0,1,2,7,3};
        int sum =0;
        int max = arr[0];
        int min = arr[0];
        for (int i = 0; i <arr.length ; i++) {
            sum +=arr[i];

            for (int j = 0; j <arr.length ; j++) {
                if (max < arr[j]) {
                    max =arr[j];;
                }

            }

            for (int k = 0; k <arr.length ; k++) {
                if (min > arr[k]) {
                    min =arr[k];;
                }

            }


        }
        int avg = (sum - max - min)/(arr.length-2);
        System.out.println(avg);
    }

}
